package com.likai.jarscms.controller;

import com.likai.jarscms.pojo.TagBean;
import com.likai.jarscms.service.ITagService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * Created by likai on 2018/10/18.
 */
@Controller
@RequestMapping(value = "/")
public class IndexController {

    /** logger */
    private static final Logger LOGGER = LoggerFactory.getLogger(IndexController.class);

    @Autowired
    private ITagService tagService ;

    @RequestMapping(value = "/index")
    public ModelAndView index(
            ModelAndView mv
    ) {

        try {
            List<TagBean> list = tagService.randomList(200) ;
            mv.setViewName("index");
            mv.addObject("tagList",list) ;
        } catch (Exception e) {
            LOGGER.error("Exception",e);
        }
        return mv ;
    }
}
